// import { createStore, applyMiddleware } from 'redux';
// import reducer from '../reducers';
// import thunk from 'redux-thunk';
// import logger from 'redux-logger';

// const store = createStore(reducer, applyMiddleware(thunk, logger));
// export default store;



import { createStore, applyMiddleware } from 'redux';
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage' // defaults to localStorage for web and AsyncStorage for react-native
import reducer from '../reducers';
import thunk from 'redux-thunk';
import logger from 'redux-logger';

const persistConfig = {
  key: 'root',
  storage,
}

const persistedReducer = persistReducer(persistConfig, reducer)
export default () => {
  let store = createStore(persistedReducer)
  let persistor = persistStore(store)
  return { store, persistor }
}